/**
  @file: DomainHostArchDef.java
  
   PURPOSE:
      This class represents an instance of a DomainHostArchDef of a Domain
      Definition.
   
   @author Ron Williams
  
   REVISION HISTORY ABSTRACT
  
   PROGRAMMER:  Ron Williams ORG: MSE
  
   Copyright 2011 Mission Solutions LLC. All rights reserved.
  
   END ABSTRACT
 */

package com.mse.utilities;

import java.lang.String;
import java.lang.StringBuilder;

import com.mse.utilities.DomainDefLimits;
import com.mse.utilities.DomainException;

/**
   DESCRIPTION:
      The DomainHostArchDef class contains the information as a result of
      parsing a Domain Definition file for a DomainHostArchDef definition. The
      attributes for the DomainHostArchDef are user defined.  However it is
      suggested that they be specified based on the results of the "uname" 
      command. Specifically:
      uname -s  --> osType
      uname -r  --> osVer
      uname -m  --> arch

      In the future, a discovery process could generate this information.
 */
public class DomainHostArchDef {

   /**
      DESCRIPTION:
         Create a DomainHostArchDef object.
      @return void
      @throws n/a
    */
   public DomainHostArchDef() {
      this.archId       = "";
      this.osType       = "";
      this.osVersion    = "";
      this.architecture = "";
   }

   /**
      DESCRIPTION:
         Create a DomainHostArchDef object based on specified attributes
      @param archId - string containing the Architecture ID
      @param osType - string identifying the type of Operating System
      @param osVer  - string identifying version of the Operating System
      @param arch   - string identifying machine architecture
      @return void
      @throws DomainException - for invalid arguments
    */
   public DomainHostArchDef(String archId, String osType, String osVer,
                            String arch) throws DomainException {
      // verify input string sizes are not too long
      if (archId.length() > DomainDefLimits.HAD_ArchID_Max) {
         throw new DomainException("HostArch, ArchID field value is too " +
                                   "large, can not exceed length: " +
                                   DomainDefLimits.HAD_ArchID_Max);
      }
      if (osType.length() > DomainDefLimits.HAD_OsType_Max) {
         throw new DomainException("HostArch, osType field value is too " +
                                   "large, can not exceed length: " +
                                   DomainDefLimits.HAD_OsType_Max);
      }
      if (osVer.length() > DomainDefLimits.HAD_OsVer_Max) {
         throw new DomainException("HostArch, osVer field value is too " +
                                   "large, can not exceed length: " +
                                   DomainDefLimits.HAD_OsVer_Max);
      }
      if (arch.length() > DomainDefLimits.HAD_Arch_Max) {
         throw new DomainException("HostArch, arch field value is too " +
                                   "large, can not exceed length: " +
                                   DomainDefLimits.HAD_Arch_Max);
      }
      this.archId       = archId;
      this.osType       = osType;
      this.osVersion    = osVer;
      this.architecture = arch; 
   }

   /**
      DESCRIPTION:
         get the Architecture Identifier
      @return archId - the architecture identifier
      @throws n/a
    */
   public String getArchId() {
      return archId;
   }

   /**
      DESCRIPTION:
         get the OS type string
      @return osType - the Operating System type
      @throws n/a
    */
   public String getOsType() {
      return osType;
   }

   /**
      DESCRIPTION:
         get the OS Version
      @return osVer - the Operating System Version
      @throws n/a
    */
   public String getOsVersion() {
      return osVersion;
   }

   /**
      DESCRIPTION:
         get the architecture
      @return arch - the architecture
      @throws n/a
    */
   public String getArchitecture() {
      return architecture;
   }
   /**
   DESCRIPTION:
      set the Architecture Identifier   
 */
public void setArchId(String s) {
   archId=s;
}

/**
   DESCRIPTION:
      set the OS type string
 */
public void setOsType(String s) {
    osType=s;
}

/**
   DESCRIPTION:
      set the OS Version
 */
public void setOsVersion(String s) {
   osVersion=s;
}

/**
   DESCRIPTION:
      set the architecture
 */
public void setArchitecture(String s) {
   architecture=s;
}
   /**
      DESCRIPTION:
         compare two DomainHostArchDef objects for equality. We consider them
         equal if the following attributes are the same.
            - archId
            - osType
            - osVersion
            - architecture

      @return boolean - true means objects are considered the same
      @throws n/a
    */
   public boolean equals(DomainHostArchDef other) {
      boolean rslt = false;      // assume objects are NOT the same

      if (this.archId.equals(other.getArchId()) && 
          this.osType.equals(other.getOsType()) &&
          this.osVersion.equals(other.getOsVersion()) &&
          this.architecture.equals(other.getArchitecture())) {
         rslt = true;
      }
      return rslt;
   }

   /**
      DESCRIPTION:
         obtain the string representation for this DomainHostArchDef
      @return text - this DomainHostArchDef info in a string for output
      @throws n/a
    */
   public String toString() {
      StringBuilder sb = new StringBuilder(128);

      sb.append("DomainHostArchDef -  archId: ");
      sb.append(archId);
      sb.append("\n             OS Type: ");
      sb.append(osType);
      sb.append("\n          OS Version: ");
      sb.append(osVersion);
      sb.append("\n        Architecture: ");
      sb.append(architecture);
      return sb.toString();
   }


//---------------------------------------------------------------PRIVATE
   private String archId;           // unique identifier
   private String osType;           // OS identifier string (uname -s)
   private String osVersion;        // OS version (uname -r)
   private String architecture;     // architecture (uname -m)

}

